package com.xumt.hwHMSdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import com.xumt.hwHMSdemo.cannectSb.HttpRequest;
import com.xumt.hwHMSdemo.ui.PersonFragment;

public class OrderManagementActivity extends AppCompatActivity {
    public static String orderlistresult;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_management);
        Button button =(Button)findViewById(R.id.ob4);
        button.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                //跳转
                Intent intent = new Intent(OrderManagementActivity.this, PersonFragment.class);
                startActivity(intent);
            }
        });
        //未支付跳转 state0
        ImageButton imageButton=(ImageButton)findViewById(R.id.ob1);
        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent(OrderManagementActivity.this, OrderActivity.class);
                getorder(0);
                startActivity(intent1);
            }
        });
        //未发货跳转
        ImageButton imageButton1=(ImageButton)findViewById(R.id.ob5);
        imageButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent2 = new Intent(OrderManagementActivity.this, OrderActivity.class);
                getorder(1);
                startActivity(intent2);
            }
        });
        //待收货跳转
        ImageButton imageButton2=(ImageButton)findViewById(R.id.ob2);
        imageButton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent3= new Intent(OrderManagementActivity.this, OrderActivity.class);
                getorder(3);
                startActivity(intent3);
            }
        });
        //已收货
        ImageButton imageButton3=(ImageButton)findViewById(R.id.ob3);
        imageButton3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent4 = new Intent(OrderManagementActivity.this, OrderActivity.class);
                getorder(4);
                startActivity(intent4);
            }
        });
    }
    private void getorder(int i){
        new Thread() {
            public void run() {
                try {
                    HttpRequest request = new HttpRequest();
                    orderlistresult = request.sendGet("http://169.254.105.90:8081/Order/state","state="+i);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }

}